<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>首页</h1>
    <a href="/upload.html">上传图片</a>
    <hr>
    <div v-for="image in arr">
        <h2>{{image.intro}}</h2>
        <img v-for="url in image.urlArr" :src="url" width="100px">
        <a href="javascript:void(0)" @click="del(image.id)">删除</a>
    </div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
        arr:[]
    },
      created:function (){
        axios.get("/select").then(function (response) {
            v.arr = response.data
            for (let image of v.arr){
                image.urlArr = image.urls.split(",")
            }
        })
      },
      methods:{
          del(id){
              //发出异步请求获取数据
              if (confirm("确定删除吗")){
                  axios.get("/delete?id="+id).then(function (response){
                      alert("删除完成!");
                      location.reload()//刷新页面
                  })
              }
          }
      }
  })
</script>
</body>
</html>